home *** CD-ROM | disk | FTP | other *** search
- John J. Maver, Jr. wrote:
- >
- > This is going to be rediculously easy to solve. thanks in advance!!
- >
- > I have a value entered as a string like,
- >
- > char *mystring;
- >
- > printf("Enter your age>");
- > scanf("%s",&mystring);
-
- Uh oh .....
-
- Are you first malloc()'ing enough space for your char string?
-
- You might try:
-
- char mystring[5];
-
- printf(...);
- scanf("%s",mystring);
-
- >
- > Now I want it to be an int, so:
- >
- > myint=atoi(mystring);
- >
- > I mess around with the int:
- >
- > myint=myint+10;
- >
-
- myint+=10; // more concise ;-)
-
- > And I want to turn myint back into a string.
- >
- > HOW???
- >
- > I am writing a small GUI-based prog that has a string gadget and a text
- > gadget. I want to be able to take an integer from the string-gad, change it,
- > and then put the answer in the text-gad.
- >
-
- You might try something which is often overlooked. sprintf()
-
- char buffer[5];
-
- sprintf(buffer, "%d", myint);
-
- > Thank you,
- >
-
- You're welcome.
-
- ===================================================
-
- Jon S. Berndt
- Aerospace Engineer
- System Administration Team
- Space Station Training Facility
- GeoLogics/Hughes Training, Inc.
- Houston, TX
-
- jsb@hal-pc.org
- jsberndt@aol.com
- http://www.hal-pc.org/~jsb
-
- ===================================================
-